/*
 * Copyright 2009 Eat Local Food, LLC
 * Copyright (c) 2007 osCommerce (this file was written after
 * code review of osCommerce).
 *
 * This file is part of gwtCommerce.
 *
 * gwtCommerce is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * gwtCommerce is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with gwtCommerce.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.elf.gwt.common.client.model;

import com.google.gwt.json.client.JSONObject;

/**
 *  
 */
public class CouponModel extends AbstractModel
{
	protected int id;
	protected String code;
	protected double amount;
	protected int type;
	protected boolean status;
	protected int use;
	
	public CouponModel() 
	{
		id = -1;
		code = "";
		amount = 0;
		type = 0;
		status = false;
		use = 0;
	}
	
	public CouponModel(JSONObject jsonObject)
	{
		id = convertToInteger(jsonObject, "id");
		code = convertToString(jsonObject, "code");
		amount = convertToDouble(jsonObject, "amount");
		type = convertToInteger(jsonObject, "type");
		status = convertToBoolean(jsonObject, "status");
		use = convertToInteger(jsonObject, "use");
	}
	
	public CouponModel(CouponModel model)
	{
		id = model.getId();
		code = model.getCode();
		amount = model.getAmount();
		type = model.getType();
		status = model.isStatus();
		use = model.getUse();
	}
	
	public int getId() {
		return id;
	}

	public String getCode() {
		return code;
	}

	public double getAmount() {
		return amount;
	}

	public int getType() {
		return type;
	}

	public boolean isStatus() {
		return status;
	}

	public int getUse() {
		return use;
	}
}
